package com.kang.controller;

import com.github.pagehelper.PageInfo;
import com.kang.bean.Dict;
import com.kang.commons.Result;
import com.kang.service.DictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @program: service
 * @description:
 * @author: K.faWu
 * @create: 2022-04-26 13:44
 **/
@RestController
@RequestMapping("dict")
public class DictController {
    @Autowired
    private DictService dictService;

    @PostMapping("getList")
    public Result<?> getList(@RequestBody Dict dict, Pageable page){
        PageInfo<Dict> pageInfo = dictService.query(dict, page);
        return Result.success(pageInfo);
    }

    @PutMapping
    public Result<?> save(@RequestBody Dict dict){
        dictService.add(dict);
        return Result.success();
    }
    @PostMapping
    public Result<?> update(@RequestBody Dict dict){
        dictService.updateById(dict);
        return Result.success();
    }
}
